<?php

	/**
	 * @see Bike_Initial
	 */
	require_once 'Bike/Initial.php';
	
	/**
	 * @see Bike_Js
	 */
	require_once 'Bike/Js.php';
	
	/**
	 * @see Bike_Js_Interface_Js
	 */
	require_once 'Bike/Js/Interface/Js.php';
	
	
	class Bike_Js_Glue extends Bike_Initial implements Bike_Js_Interface_Js
	{
		private $_methodName;
		private $_args;

		static public function js()
		{
			return Bike_Js::getInstance();
		}
		
		static public function factory()
		{
			$args = func_get_args();
			$glue = new self();
			$glue->setOptions($glue->makeOptions($args));
			return $glue;
		}

        public function makeOptions(array $Args=null)
		{
			return $options = array();
		}

	    public function __toString()
	    {	    	return '';
	    }
	    
	    public function clearStrCache()
	    {
	    	
	    }
	    
	    public function __clone()
	    {
	    	$this->clearStrCache();
	    }

	    public function toJson()
		{
			return $this->__toString();
		}

		public function __call($MethodName, array $Args=null)
		{			try
			{
				return parent::__call($MethodName, $Args);
			}
			catch(Bike_Exception $e)
			{
				if(substr($MethodName, 0, 1) == '_')
				{
					$this->_methodName = $MethodName;
					$this->_args = $Args;
					return $this;
				}
				require_once 'Bike/Js/Exception.php';
				throw new Bike_Js_Exception('Undefined method "'.$MethodName.'"');
			}
		}

		public function getMethodName()
		{			return $this->_methodName;
		}

		public function getArgs()
		{
			return (array) $this->_args;
		}
	}
